﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mitc.Portal.Core.Entitys.Calendar;
using SPGenesis.Core;
using Microsoft.SharePoint;
using Mitc.Portal.Core.CoreHelper;

namespace Mitc.Portal.Core.Entitys.Calendar
{
    [SPGENListInstance(
        WebRelURL = "Lists/ToCalendar",
        Title = "ToCalendar",      
        OnQuickLaunch = false,
        TemplateType = (int)SPListTemplateType.GenericList)]
    public partial class CalendarIntance:SPGENListInstance<CalendarIntance>
    {
        protected override void InitializeDefinition(SPGENListInstanceProperties properties)
        {
            properties.Fields.ProvisioningMode = SPGENProvisioningMode.ExclusiveAdd;
            properties.Fields.Add<TypeOfCal>(true, false);
            properties.Fields.Add<Sponsor>(true, false);
            properties.Fields.Add<FromDate>(true, false);
            properties.Fields.Add<EndofDate>(true, false);
            properties.Fields.Add<ObjectMain>(true, false);
            properties.Fields.Add<NewsContents>(true, false);
            properties.Fields.Add<Address>(true, false);
            properties.Fields.Add<Concern>(true, false);                      
        }

        [SPGENField(AllowMultipleValues = false, ID = "{89C94E7C-9DE7-425D-BF2D-C5BABE1A622D}", DisplayName = "Loại lịch", Type = SPFieldType.Choice, Required = false)]
        public class TypeOfCal : SPGENField<TypeOfCal, SPFieldChoice, string>
        {
            protected override void InitializeDefinition(SPGENFieldProperties<SPFieldChoice> properties)
            {
                properties.ChoiceMappings.Clear();

                properties.ChoiceMappings.Add("1", StringHelper.GetDescriptionEnum(CalendarType.Lichcongtac));
                properties.ChoiceMappings.Add("2", StringHelper.GetDescriptionEnum(CalendarType.Lichkythuat));
                properties.ChoiceMappings.Add("3", StringHelper.GetDescriptionEnum(CalendarType.Lichphonghop));
                properties.ChoiceMappings.Add("4", StringHelper.GetDescriptionEnum(CalendarType.Lichtruckenh));
                properties.ChoiceMappings.Add("5", StringHelper.GetDescriptionEnum(CalendarType.LichTruongquay));
                properties.ChoiceMappings.Add("6", StringHelper.GetDescriptionEnum(CalendarType.LichXe));
                properties.DefaultValue = StringHelper.GetDescriptionEnum(CalendarType.Lichcongtac);
            }
        }
  
      

        [SPGENField(AllowMultipleValues = false, ID = "{2344243C-16FB-43D7-AD97-DC507A9DDFD4}", DisplayName = "Chủ trì", Type = SPFieldType.User, Required = false)]
        public class Sponsor : SPGENField<Sponsor, SPFieldUser, SPFieldUserValue>
        {
        }

        [SPGENField(AllowMultipleValues = false, ID = "{4CCFF921-20DE-4188-9FC0-148F44A6D499}", DisplayName = "Ngày bắt đầu", Type = SPFieldType.DateTime, Required = false)]
        public class FromDate : SPGENField<FromDate, SPFieldDateTime, DateTime>
        {
        }

        [SPGENField(AllowMultipleValues = false, ID = "{6A06C735-91AC-4F8C-97DA-3AA30A95A834}", DisplayName = "Ngày kết thúc", Type = SPFieldType.DateTime, Required = false)]
        public class EndofDate : SPGENField<EndofDate, SPFieldDateTime, DateTime>
        {
        }

        [SPGENField(AllowMultipleValues = false, ID = "{F3E1055C-8F7F-46A5-83D7-5AB734DB3E54}", DisplayName = "Họ và tên", Type = SPFieldType.User, Required = false)]
        public class ObjectMain : SPGENField<ObjectMain, SPFieldUser, SPFieldUserValue>
        {
        }

        [SPGENField(ID = "{7D57E601-F99E-45AB-BBF4-536804AF4293}", DisplayName = "Nội dung", Type = SPFieldType.Note, Required = false)]
        public class NewsContents : SPGENField<NewsContents, SPFieldMultiLineText, string>
        {
            
        }

        [SPGENField(ID = "{20FCB2A1-6CFE-4332-B775-9BD3C7089902}", DisplayName = "Thành phần", Type = SPFieldType.Text, Required = false)]
        public class Concern : SPGENField<Concern, SPFieldText, string>
        {

        }

        [SPGENField(ID = "{B5CC1388-205F-4C2C-AD36-D3463BA7B811}", DisplayName = "Địa điểm", Type = SPFieldType.Text, Required = false)]
        public class Address : SPGENField<Address, SPFieldText, string>
        {

        }
    }
}
